<?php

namespace app\factory\controller;

use app\common\respond\HttpApi;
use app\factory\logic\BarnLogic;

class BarnController
{
    /**
     * @Description 新增/编辑
     * @author: zj
     * @param HttpApi $respond
     * @time 2024/03/11 16:20:02
     * @return \think\response\Json
     */
    public function addEdit(HttpApi $respond)
    {
        $param = [
            'Id' => (int)request()->post('Id'),
            'Name' => request()->post('Name'),
            'IPAddress' => request()->post('IPAddress'),
            'FeedBaseTime' => request()->post('FeedBaseTime'),
            'FeedPreDayId' => (int)request()->post('FeedPreDayId') ?: 0,
            'RecordTime' => request()->post('RecordTime')
        ];
        $rule = [
            'Id' => 'require|integer|>:0',
            'RecordTime' => 'require|integer|>:0',
        ];
        validate($rule)->check($param);

        $logic = new BarnLogic();
        $data = $logic->addEdit($param['Id'], $param);

        return $respond->success([]);
    }
}
